package speed;

public class FloatOrDouble {
	public static void main(String[] args) {
		double n1=3.1415926535;
		float n2=3.1415926535f;
		System.out.println(n1+"\n"+n2);//精度不够
		double num1 = 2.7;
		double num2 = 8.1/3;   //计算机浮点数采用二进制表示
	    									//0.1的小数在二进制下为无限循环的小数，无法精确表述
		System.out.println(num1==num2);
		System.out.println(num1+"\n"+num2);
		
		//solution
		if (Math.abs(num2-num1)<=0.00001) {
			System.out.println("二者相同");
		} else {
			System.out.println("二者不相同");
		}
		
		
	}

}
